<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /* 
      promise实例
        promise实例有两个属性
        - promiseState:代表的是当前promise实例的状态
          - pending:正在进行中(默认值,只有Promise构造函数的回调函数内部调用了resolve或reject才能改变)
          - fulfilled:成功状态
          - rejected:失败状态

        - promiseResult:promise实例的值(一般是Promise成功或者失败后需要携带的值)
          - 默认是undefined
          - 如果resolve或reject函数中传递了参数,则这个值就是他俩函数中的实参
    
    
    */
     const p1 = new Promise((resolve,reject)=>{
        setTimeout(()=>{
            console.log('异步完成')
            resolve('ok')
            reject('error')
        },2000)
     }) 
    // const p1 = new Promise((resolve, reject) => {
    //   setTimeout(() => {
    //     console.log("异步操作已经完成");
    //     // resolve("ok")
    //     reject("error")
    //   }, 2000)
    // })

    console.log("p1", p1);
  </script>
</body>

</html>